<?php
include_once dirname(__FILE__) . '/filtro_usuario.php';
include_once dirname(__FILE__) . '/funciones/basicas.php';
include_once dirname(__FILE__) . '/datos/MenuDao.php';
include_once dirname(__FILE__) . '/clases/utiles/Menu.class.php';

$conexion = conectarPDO();
$menuDao = new MenuDao($conexion);
$menu = new  Menu();
$menu->setMenuDao($menuDao);
$menu->setPerfil(strtoupper($_SESSION['perfil']));
$menu->setTarget('iframe');
$menu->setUrlBase($_SESSION['BASE']); 

?>
<html>
<head>
<title>::Sistema de Ventas::</title>
<?php include_once dirname(__FILE__) . '/header.php'; ?>
<link rel="stylesheet" href="<?php echo $_SESSION['BASE'] ?>/js/jqwidgets/styles/jqx.base.css" type="text/css" />    
<script type="text/javascript" src="<?php echo $_SESSION['BASE'] ?>/js/jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="<?php echo $_SESSION['BASE'] ?>/js/jqwidgets/jqxbuttons.js"></script>
<script type="text/javascript" src="<?php echo $_SESSION['BASE'] ?>/js/jqwidgets/jqxscrollbar.js"></script>
<script type="text/javascript" src="<?php echo $_SESSION['BASE'] ?>/js/jqwidgets/jqxpanel.js"></script>
<script type="text/javascript" src="<?php echo $_SESSION['BASE'] ?>/js/jqwidgets/jqxtree.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            // Create jqxTree
            $('#jqxTree').jqxTree({ height: '300px', width: '300px' });
//             $('#jqxTree').bind('select', function (event) {
//                 var htmlElement = event.args.element;
//                 var item = $('#jqxTree').jqxTree('getItem', htmlElement);
//                 alert(item.label);
//             });
        });
    </script>
<script type="text/javascript">

/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById)
{  //DynamicDrive.com change
   document.write('<style type="text/css">\n')
   document.write('.submenu{display: none;}\n')
   document.write('</style>\n')
}

function SwitchMenu(obj)
{
    if(document.getElementById){
    var el = document.getElementById(obj);
    var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
        if(el.style.display != "block"){ //DynamicDrive.com change
            for (var i=0; i<ar.length; i++){
                if (ar[i].className=="submenu") //DynamicDrive.com change
                ar[i].style.display = "none";
            }
            el.style.display = "block";
        }else{
            el.style.display = "none";
        }
    }
}

function get_cookie(Name)
{ 
    var search = Name + "="
    var returnvalue = "";
    if (document.cookie.length > 0)
    {
        offset = document.cookie.indexOf(search)
        if (offset != -1)
        { 
            offset += search.length
            end = document.cookie.indexOf(";", offset);
            if (end == -1) end = document.cookie.length;
            returnvalue=unescape(document.cookie.substring(offset, end))
        }
    }
    return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate

</script>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.Estilo2 {
	color: #666666;
	font-size: 10px;
	font-family: Geneva, Arial, Helvetica, sans-serif;
}
-->
</style>
</head>
<body>
    
<!--Tabla principal de contenido-->
<table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0">
    <tr height="76">
    <td bgcolor="#FFFFFF" scope="row" background="<?php echo $_SESSION['BASE'] . '/img/bar.png' ?>">
    <div align="left">
    <img title="Logotipo" src="<?php echo $_SESSION['BASE'] . '/img/logo.png' ?>" width="208" height="76">
    </div>
    </td>
    </tr><tr>
    <td>
    <!--Tabla de contenido-->
    <table border="0" height="100%" width="100%">
	<tr>
	<td width="12%">
        <div id='jqxTree'>
        <ul>
            <?php
//             foreach($rootMenu as $root){
//                 echo "<li>";
//                 echo $root['menu_nombre'];
//                 $menuHijos = $menuDao->getMenu($root['menu_id'], strtoupper($_SESSION['perfil']));
//                 if(count($menuHijos) > 0){
//                     echo "<ul>";
//                     foreach($menuHijos as $hijo){
//                         echo "<li>" . $hijo['menu_nombre'] . "</li>";
//                     }                    
//                     echo "</ul>";
//                 }
//                 echo "</li>";
//             }   
            echo $menu->getMenu(1);
            ?>
          <!--  <li item-selected='true'>Home</li>
            <li item-expanded='true'>Solutions
              <ul>
                  <li>Education</li>
                  <li>Financial services</li>
                  <li>Government</li>
                  <li>Manufacturing</li>
                  <li>Solutions
                        <ul>
                            <li>Consumer photo and video</li>
                            <li>Mobile</li>
                            <li>Rich Internet applications</li>
                            <li>Technical communication</li>
                            <li>Training and eLearning</li>
                            <li>Web conferencing</li>
                        </ul>
                  </li>
                  <li>All industries and solutions</li>
              </ul>
            </li>-->
        </ul>
            </div><br>
            <!--Tabla de menu-->
            <table border="0"  cellpadding="1" cellspacing="1">
                <tr>
                <th width="150" scope="row">
                <div id="masterdiv">
                <div class="menutitle" onClick="SwitchMenu('sub1')">
                <a href="#"><img src="<?php echo $_SESSION['BASE'] . '/img/community_users.png' ?>" name="image3" border="0" id="image3">
                <br /><span class="Estilo10">Usuarios</span></a>
                </div>
                <span class="submenu" id="sub1">
                <div align="left">
                <table bgcolor="#000000" cellspacing="1" cellpadding="1" width="150">
                <tr>
                    <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/mantenedor_usuarios/crear_usuario.php' ?>" target="iframe">-Crear Usuario</a>
                </td>
                </tr><tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/mantenedor_usuarios/buscar_usuario.php' ?>" target="iframe">-Buscar Usuario</a>
                </td>
                </tr>

                </table>
                </div>
                </span>
                </div>
                </th>
                </tr>
                    <tr>
                    <th width="150" scope="row">
                <div id="masterdiv">
                <div class="menutitle" onClick="SwitchMenu('sub2')">
                <a href="#"><img src="<?php echo $_SESSION['BASE'] . '/img/shopping_cart.png' ?>" name="image3" border="0" id="image3">
                <br /><span class="Estilo10">Productos</span></a>
                </div>
                <span class="submenu" id="sub2">
                <div align="left">
                <table bgcolor="#000000" cellspacing="1" cellpadding="1" width="150">
                <tr><td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/mantenedor_productos/crear_producto.php' ?>" target="iframe">-Crear Producto</a>
                </td>
                </tr><tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/mantenedor_productos/buscar_producto.php' ?>" target="iframe">-Buscar Producto</a>
                </td>
                </tr><tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/mantenedor_productos/ingreso_directo_producto.php' ?>" target="iframe">-Ingreso Directo Producto</a>
                </td>
                </tr><tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/factura_prove/ingreso_producto_factura.php' ?>" target="iframe">-Ingreso de producto con factura</a>
                </td>
                </tr></table>
                </div>
                </span>
                </div>
                </th>
                    </tr>
                    <tr>
                <th width="150" class="Estilo10" scope="row">
                <div id="masterdiv">
                <div class="menutitle" onClick="SwitchMenu('sub3')">
                <a href="#"><img src="<?php echo $_SESSION['BASE'] . '/img/proveedor.png' ?>" name="image2" border="0" id="image2">
                <br />Proveedores</a>
                </div>
                <span class="submenu" id="sub3">
                <div align="left">
                <table bgcolor="#000000" cellspacing="1" cellpadding="1" width="150">
                <tr><td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/mantenedor_proveedores/crear_proveedor.php' ?>" target="iframe">-Crear Proveedor</a>
                </td></tr>
                <tr><td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/mantenedor_proveedores/buscar_proveedor.php' ?>" target="iframe">-Buscar Proveedor</a>
                </td></tr>
                </table>
                </div>
                </span>
                </div>
                </th>
                    </tr>
                    <tr>
                <th width="150" scope="row">
                <div id="masterdiv">
                <div class="menutitle" onClick="SwitchMenu('sub4')">
                <a href="#"><img src="<?php echo $_SESSION['BASE'] . '/img/user.png' ?>" name="image1" border="0" id="image1">
                <br /><span class="Estilo10">Clientes</span></a>
                </div>
                <span class="submenu" id="sub4">
                <div align="left">
                <table bgcolor="#000000" cellspacing="1" cellpadding="1" width="150">
                <tr><td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/mantenedor_clientes/crear_cliente.php' ?>" target="iframe">-Crear Cliente</a>
                </td></tr>
                <tr><td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/mantenedor_clientes/buscar_cliente.php' ?>" target="iframe">-Buscar Cliente</a>
                </td></tr>
                </table>
                </div>
                </span>
                </div>
                </th>
                    </tr>
                    <tr>
                <th width="150" scope="row">
                <div id="masterdiv">
                <div class="menutitle" onClick="SwitchMenu('sub5')">
                <a href="#"><img src="<?php echo $_SESSION['BASE'] . '/img/shopping_cart_accept.png' ?>" name="image1" border="0" id="image1">
                <br /><span class="Estilo10">Ventas</span></a>
                </div>
                <span class="submenu" id="sub5">
                <div align="left">
                <table bgcolor="#000000" cellspacing="1" cellpadding="1" width="150">
                <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/factura/facturar.php' ?>" target="iframe">-Crear Factura</a>
                </td>
                </tr>
                <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/factura/buscar_factura.php' ?>" target="iframe">-Buscar Factura</a>
                </td>
                </tr>
                <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/factura/buscar_factura.php' ?>" target="iframe">-Crear nota de credito</a>
                </td>
                </tr>
                <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/nota_credito/buscar_nota_credito.php' ?>" target="iframe">-Buscar nota de credito</a>
                </td>
                </tr>
                <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/guia_despacho/guia.php' ?>" target="iframe">-Crear guia de despacho</a>
                </td>
                </tr>
                <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/guia_despacho/buscar_guia.php' ?>" target="iframe">-Buscar guia de despacho</a>
                </td>
                </tr>
                <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/cotizacion/cotizacion.php' ?>" target="iframe">-Crear cotizacion</a>
                </td>
                </tr>
                          <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/cotizacion/buscar_cotizacion.php' ?>" target="iframe">-Buscar cotizacion</a>
                </td>
                </tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/notaVenta/notaVenta.php' ?>" target="iframe">-Crear nota de venta</a>
                </td>
                </tr>
                          <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/notaVenta/buscarNotaVenta.php' ?>" target="iframe">-Buscar nota de venta</a>
                </td>
                </tr>
                <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/facturas_por_cobrar/facturas_por_cobrar.php' ?>" target="iframe">-Facturas por cobrar</a>
                </td>
                </tr>
                <tr><td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/ventas/ventas.php' ?>" target="iframe">-Reporte de ventas mensuales</a>
                </td>
                </tr>
                <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/ventas_por_vendedor/ventas_por_vendedor.php' ?>" target="iframe">-Ventas por Vendedor</a>
                </td>
                </tr>
                <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/buscar_producto_vendido/buscar_producto_vendido.php' ?>" target="iframe">-Buscar producto vendido por cliente</a>
                </td>
                </tr>
                <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . "/buscar_producto_vendido_por_producto/buscar_producto_vendido.php" ?>" target="iframe">-Buscar producto vendido por producto</a>
                </td>
                </tr>
                </table>
                </div>
                </span>
                </div>
                </th>
                    </tr>
                    <tr>
                <th width="150" class="Estilo10" scope="row">
                <div id="masterdiv">
                <div class="menutitle" onClick="SwitchMenu('sub6')">
                <a href="#"><img src="<?php echo $_SESSION['BASE'] . '/img/shopping_cart_down.png' ?>" name="image2" border="0" id="image2">
                <br />Compras</a>
                </div>
                <span class="submenu" id="sub6">
                <div align="left">
                <table bgcolor="#000000" cellspacing="1" cellpadding="1" width="150">
                <tr><td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/compras/compras.php' ?>" target="iframe">-Listado de compra</a>
                </td></tr>
                <tr><td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/factura_prove/buscar_factura_proveedor.php' ?>" target="iframe">-Buscar factura de compra</a>
                </td></tr>
                <tr><td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/facturas_por_pagar/facturas_por_pagar.php' ?>" target="iframe">-Facturas por pagar</a>
                </td></tr>
                <tr><td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/buscar_producto_comprado/buscar_producto_comprado.php' ?>" target="iframe">-Buscar producto comprado</a>
                </td></tr>
                <tr><td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/orden_de_compra/orden_de_compra.php' ?>" target="iframe">-Crear orden de compra</a>
                </td></tr>
                <tr><td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/orden_de_compra/buscar_orden_de_compra.php' ?>" target="iframe">-Buscar Orden de compra</a>
                </td></tr>
                </table>
                </div>
                </span>
                </div>
                </th>
                     </tr>
                <tr>
                <th width="150" class="Estilo10" scope="row">
                <a href="<?php echo $_SESSION['BASE'] . '/busqueda_rapida/busqueda_rapida.php' ?>" target="iframe">
                <img src="<?php echo $_SESSION['BASE'] . '/img/database_search.png' ?>" border="0"> 
                <br />Busqueda rapida
                </a>
                </th>
                     </tr>
                <tr>
                <th width="150" class="Estilo10" scope="row">
                <a href="<?php echo $_SESSION['BASE'] . '/listar/listar.php' ?>" target="iframe">
                <img src="<?php echo $_SESSION['BASE'] . '/img/application.png' ?>" border="0">
                <br />Listados
                </a>
                </th>
                     </tr>
                <tr>
                <th width="150" class="Estilo10" scope="row">
                <div id="masterdiv">
                <div class="menutitle" onClick="SwitchMenu('sub7')">
                <a href="#">
                <img src="<?php echo $_SESSION['BASE'] . '/img/process.png' ?>" name="image2" border="0" id="image2">
                <br />Configuracion</a>
                </div>
                <span class="submenu" id="sub7">
                <div align="left">
                <table bgcolor="#000000" cellspacing="1" cellpadding="1" width="150">
                <tr>
                <td bgcolor="#ffffff">
                <a href="<?php echo $_SESSION['BASE'] . '/datos_empresa/datos_empresa.php' ?>" target="iframe">-Datos de empresa</a>
                </td>
                </tr>
                </table>
                </div>
                </span>
                </div>
                </th>
                </tr>        
            </table>           
            <!--Fin tabla de menu-->
        </td><td>
	    <iframe frameborder="0" name="iframe" src="" marginheight="0" marginwidth="0" scrolling="auto"  height="100%" width="100%"></iframe>
        </td>
	</tr>
    </table>
    <!--Fin tabla de contenido-->
    </td>
    </tr><tr height="50">
    <td background="img/bar_down.png" class="Estilo2" align="center">
	<?php echo $_SESSION['datos_empresa']['razon_social'] . '<br />' . $_SESSION['datos_empresa']['email'] . ' ' . $_SESSION['datos_empresa']['fono']; ?>
    </td>
    </tr>
</table>

<!--Boton para desconectar-->
<div style="position:absolute;top:10px;left:80%;">
 <a href="index.php?logout=logout"><img src="<?php echo $_SESSION['BASE'] . '/img/LogOff.png' ?>" width="45" height="45" border="0"></a>
</div>
<!--Sombra superior-->
<div style="position:absolute;top:76px;left:0px; width:100%; height:7px; background:url(img/sombra.png) repeat-x">
&nbsp;
</div>
<!--Nombre de usuario conectado-->
<div style="position:absolute;top:10px;left:35%;">
 <font color="#666666">Conectado como: <?php echo $_SESSION['nomUsuario']; ?></font>
</div>

</body>
</html>